<?php


namespace Xiaoguai\DesignPattern\DP009;


class Context
{
    /**
     * @var StrategyInterface $strategy
     */
    protected $strategy;

    public function __construct(StrategyInterface $strategy)
    {
        $this->strategy = $strategy;
    }
    
    /**
     * @return StrategyInterface
     */
    public function getStrategy(): StrategyInterface
    {
        return $this->strategy;
    }

    /**
     * @param StrategyInterface $strategy
     */
    public function setStrategy(StrategyInterface $strategy): void
    {
        $this->strategy = $strategy;
    }

    public function action()
    {
        return $this->strategy->action();
    }
}